Skip to content

fix: Revert sqlparse parsing limits to pre-0.5.4 defaults#77

Merged
m1so merged 2 commits intomainfrom
michalbaumgartner/blu-5817-revert-sqlparse-parsing-limits-to-pre-054-defaults
Mar 17, 2026
Merged

fix: Revert sqlparse parsing limits to pre-0.5.4 defaults#77
m1so merged 2 commits intomainfrom
michalbaumgartner/blu-5817-revert-sqlparse-parsing-limits-to-pre-054-defaults

Conversation

@m1so
Copy link
Contributor

@m1so m1so commented Mar 17, 2026

Summary by CodeRabbit

  • New Features

    • Added optional runtime configuration for SQL parser limits, allowing control of token/depth thresholds and applying safe defaults automatically.
  • Tests

    • Added unit tests covering configuring, resetting, and behavior of SQL parsing limits, including large-query parsing scenarios.

@m1so m1so requested a review from mfranczel March 17, 2026 15:39
@linear
Copy link

linear bot commented Mar 17, 2026

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Added runtime configuration for sqlparse grouping limits via new functions configure_sqlparse_limits() and reset_sqlparse_limits() in deepnote_toolkit.sql.sql_utils. init_deepnote_runtime() now calls configure_sqlparse_limits() after output middleware setup, with errors logged but not propagated. Unit tests were added to validate enabling, disabling, and resetting limits and parsing behavior under different limit states.

Sequence Diagram(s)

sequenceDiagram
  participant RuntimeInit as RuntimeInit
  participant OutputMW as OutputMiddleware
  participant SQLUtils as sql_utils.configure_sqlparse_limits
  participant Sqlparse as sqlparse
  participant Logger as Logger

  RuntimeInit->>OutputMW: setup output middleware
  RuntimeInit->>SQLUtils: call configure_sqlparse_limits()
  SQLUtils->>Sqlparse: import sqlparse.engine.grouping
  alt grouping API available
    SQLUtils->>Sqlparse: set MAX_GROUPING_TOKENS / MAX_GROUPING_DEPTH
    Sqlparse-->>SQLUtils: attributes updated
    SQLUtils-->>RuntimeInit: return success
  else API missing or error
    SQLUtils->>Logger: log ImportError/AttributeError
    SQLUtils-->>RuntimeInit: return (no-op)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Updates Docs ⚠️ Warning PR adds public configuration APIs without corresponding documentation updates in either the main or internal repositories. Document new configure_sqlparse_limits() and reset_sqlparse_limits() functions in user-facing docs with parameters, purpose, and usage examples.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding configuration APIs and runtime initialization for sqlparse limits to address pre-0.5.4 behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Ruff (0.15.6)
tests/unit/test_sql_utils.py

Unexpected Ruff issue shape at index 1


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 17, 2026

📦 Python package built successfully!

  • Version: 2.1.3.dev3+45d75c3
  • Wheel: deepnote_toolkit-2.1.3.dev3+45d75c3-py3-none-any.whl
  • Install:
    pip install "deepnote-toolkit @ https://deepnote-staging-runtime-artifactory.s3.amazonaws.com/deepnote-toolkit-packages/2.1.3.dev3%2B45d75c3/deepnote_toolkit-2.1.3.dev3%2B45d75c3-py3-none-any.whl"

@mfranczel mfranczel marked this pull request as ready for review March 17, 2026 15:41
@mfranczel mfranczel requested a review from a team as a code owner March 17, 2026 15:41
mfranczel
mfranczel previously approved these changes Mar 17, 2026
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.71%. Comparing base (595046a) to head (2571c85).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
deepnote_toolkit/runtime_initialization.py 16.66% 5 Missing ⚠️
deepnote_toolkit/sql/sql_utils.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
- Coverage   73.75%   73.71%   -0.04%     
==========================================
  Files          93       93              
  Lines        5269     5284      +15     
  Branches      766      766              
==========================================
+ Hits         3886     3895       +9     
- Misses       1138     1144       +6     
  Partials      245      245              
Flag Coverage Δ
combined 73.71% <60.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/test_sql_utils.py`:
- Around line 13-50: The tests and fixture lack explicit return type
annotations; add return type hints to the autouse fixture
disable_sqlparse_limits (-> Iterator[None] or -> None depending on preferred
fixture typing) and to all test methods and the helper _build_large_select
(e.g., _build_large_select(num_columns: int = 5000) -> str, test_* -> None),
keeping existing signatures and imports intact; ensure you import typing symbols
if needed and do not change behavior of configure_sqlparse_limits,
reset_sqlparse_limits, is_single_select_query, or SQLParseError usages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d7037270-7aaf-43f8-811e-d4fffeb5eeee

📥 Commits

Reviewing files that changed from the base of the PR and between 595046a and ea9e099.

📒 Files selected for processing (3)
  • deepnote_toolkit/runtime_initialization.py
  • deepnote_toolkit/sql/sql_utils.py
  • tests/unit/test_sql_utils.py

@deepnote-bot
Copy link

deepnote-bot commented Mar 17, 2026

🚀 Review App Deployment Started

📝 Description 🌐 Link / Info
🌍 Review application ra-77
🔑 Sign-in URL Click to sign-in
📊 Application logs View logs
🔄 Actions Click to redeploy
🚀 ArgoCD deployment View deployment
Last deployed 2026-03-17 15:57:00 (UTC)
📜 Deployed commit 9a745743609c984d02d8188392f7eeac4263ee81
🛠️ Toolkit version 45d75c3

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/test_sql_utils.py`:
- Around line 13-14: The pytest fixture disable_sqlparse_limits should declare
its scope explicitly to signal per-test behavior; update the `@pytest.fixture`
decorator on the disable_sqlparse_limits fixture to include scope='function' so
intent is clear (i.e., change `@pytest.fixture` to
`@pytest.fixture`(scope='function')) while leaving the fixture body and
autouse=True unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dec8c247-a0a6-44e8-afac-e67f59d0ccc6

📥 Commits

Reviewing files that changed from the base of the PR and between ea9e099 and 2571c85.

📒 Files selected for processing (1)
  • tests/unit/test_sql_utils.py

@m1so
Copy link
Contributor Author

m1so commented Mar 17, 2026

admin merging to release the hotfix asap

will address dependency updates in a follow up PR to unblock CI / Audit checks

@m1so m1so merged commit 65e194d into main Mar 17, 2026
29 of 32 checks passed
@m1so m1so deleted the michalbaumgartner/blu-5817-revert-sqlparse-parsing-limits-to-pre-054-defaults branch March 17, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants